<template>
  <d2-container>
     <template slot="header" v-if="type === 'edit'">期货费用管理-修改</template>
    <template slot="header" v-if="type === 'copy'">期货费用管理-复制</template>
    <template slot="header" v-if="type === 'look'">费用管理-查看</template>
    <el-card shadow="never" class="d2-mb titleline">
     <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
         <p class="title_l fl">主要信息</p>
     </template>
      <el-form
        class="filter-container"
        ref="FYForm"
        :model="FYForm"
        label-width="110px"
      >
        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item label="部门名称">
              <el-select
                v-model="FYForm.department"
                placeholder="请选择" :disabled="type === 'look'"
                style="width:100%;"
              >
                <el-option
                  v-for="item in selectDepartsList"
                  :key="item.department"
                  :label="item.name"
                  :value="item.department"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
           <el-col :span="4" v-if="type === 'edit'">
            <el-form-item label="单据ID">
              <el-input v-model="FYForm.invoices_no" :disabled="type === 'look'"></el-input>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="单据日期">
              <el-date-picker
              v-model="FYForm.date"
              type="date" :disabled="type === 'look'"
               value-format="yyyy-MM-dd"
                style="width:140px;"
              placeholder="选择日期">
            </el-date-picker>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="购销类型">
                <el-select  clearable v-model="FYForm.direction" class="filter-item" placeholder="请选择" :disabled="type === 'look'">
              <el-option label="销售" value="1"></el-option>
              <el-option label="采购" value="0"></el-option>
            </el-select>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="原币币种">
               <el-select
                v-model="FYForm.currency"
                placeholder="请选择" :disabled="type === 'look'"
                style="width:100%;"
              >
               <el-option
                         v-for="item in selectCurrencyList"
                         :key="item.currency"
                         :label="item.name"
                         :value="item.currency"
                 >
                     <span style="float: left">{{item.name}}</span>
                     <!-- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.currency}}</span> -->
                 </el-option>
              </el-select>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="原币金额">
             <el-input-number v-model="FYForm.original_price" size="small" :precision="2" :step="0.1" :disabled="type === 'look'"></el-input-number>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="汇率">
              <el-input-number v-model="FYForm.exchange_rate" size="small" :precision="2" :step="0.1" :disabled="type === 'look'"></el-input-number>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="本币金额">
             <el-input-number v-model="FYForm.currency_price" size="small" :precision="2" :step="0.1" :disabled="type === 'look'"></el-input-number>
            </el-form-item>
          </el-col>
           <!-- <el-col :span="4">
            <el-form-item label="客商">
              <el-input v-model="FYForm.customer"></el-input>
            </el-form-item>
          </el-col> -->
           <el-col :span="4">
            <el-form-item label="期初标识*">
               <el-select  clearable v-model="FYForm.begin_flag" class="filter-item" placeholder="请选择" :disabled="type === 'look'">
               <el-option label="是" value="1"></el-option>
               <el-option label="否" value="0"></el-option>
            </el-select>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="已匹配金额">
              <el-input-number v-model="FYForm.matched_price" size="small" :precision="2" :step="0.1" disabled></el-input-number>
            </el-form-item>
          </el-col>
           <el-col :span="4">
            <el-form-item label="未匹配金额">
             <el-input-number v-model="FYForm.unmatched_price" size="small" :precision="2" :step="0.1" disabled></el-input-number>
            </el-form-item>
          </el-col>
           <!-- <el-col :span="4">
            <el-form-item label="申请人">
              <el-input v-model="FYForm.application"></el-input>
            </el-form-item>
          </el-col> -->
           <el-col :span="4">
            <el-form-item label="备注">
              <el-input v-model="FYForm.remark" :disabled="type === 'look'"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card shadow="never" class="d2-mb titleline">
     <template slot="header" style="height:66px;">
        <span class="title_x el-button--primary fl"></span>
         <p class="title_l fl">费用分配</p>
     </template>
      <!-- <el-card shadow="never" class="d2-mb"> -->
        <div class="tl mb10">
          <el-button type="default" size="small" @click="addRow">
          <d2-icon name="plus" />
          增行
        </el-button>
        <el-button type="default" size="small" icon="el-icon-delete" @click="delData">
          删行
        </el-button>
         <!-- <el-button type="default" size="small" icon="el-icon-delete" @click="handle_count">
          计算
        </el-button> -->
        </div>
       <el-table :data="fygltableData" ref="table" tooltip-effect="dark" border stripe style="width: 100%" :row-class-name="tableRow"
        :cell-style="{ 'text-align': 'center' }"
        :header-cell-style="{ 'text-align': 'center' }" @selection-change='selectRow'>
              <el-table-column type="selection" width="45" align="center"></el-table-column>
              <el-table-column label="序号"  type="index" width="75" sortable align="center"></el-table-column>
              <el-table-column  label="费用类型" align="center">
                <template slot-scope="scope">
                 <el-select v-model="scope.row.cap_type_name" :disabled="type === 'look'" placeholder="请选择" style="width:100%;" @change="selectcapItem($event, scope.$index)" value-key="cap_type">
                        <el-option
                          v-for="item in cap_typeList"
                          :key="item.cap_type"
                          :label="item.cap_type_name"
                          :value="{
                          cap_type: item.cap_type,
                          cap_type_name: item.cap_type_name
                        }"
                        >
                          <span style="float: left">{{item.cap_type_name}}</span>
                          <!-- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.cap_type}}</span> -->
                        </el-option>
                      </el-select>
                </template>
              </el-table-column>
               <el-table-column  label="策略名称" align="center" width="145">
                <template slot-scope="scope">
                  <el-input prop="strategy" class="post_name" v-model="scope.row.strategy" style="width:60px;margin-right:5px;" v-if="a"></el-input>
                  <el-input class="id dib" v-model="scope.row.strategy_name" style="width:60px;margin-right:5px;" disabled></el-input>
                  <el-button type="primary" :disabled="type === 'look'" size="mini" plain @click="CKIddia(scope.row)">选择</el-button>
                </template>
              </el-table-column>
               <!-- <el-table-column  label="单据数量" align="center" width="145">
                <template slot-scope="scope">
                  <el-input prop="invoice_vol" class="invoice_vol" v-model="scope.row.invoice_vol" @input="countChange2"></el-input>
                </template>
              </el-table-column> -->
               <el-table-column label="匹配金额">
                <template slot-scope="scope">
                  <el-input class="alloc_amount" type="number" :disabled="type === 'look'" v-model="scope.row.alloc_amount" @input="countChange1" placeholder="不填按单据数量自动匹配"></el-input>
                </template>
              </el-table-column>
               <el-table-column  label="备注" align="center">
                <template slot-scope="scope">
                  <el-input prop="remark" class="post_name" :disabled="type === 'look'" v-model="scope.row.remark"></el-input>
                </template>
              </el-table-column>
        </el-table>
    </el-card>
    <el-button type="primary" size="small" style="float:right;margin-left: 10px;" @click="FYglChange" v-if="type !== 'look'">保存</el-button>
    <el-button
      type="primary"
      size="mini"
      style="float: right; margin-left: 10px"
      @click="handle_FH"
      v-if="type === 'look'"
      >返回</el-button
    >
    <!-- <el-button type="default" size="small" style="float:right">取消</el-button> -->
     <!-- 策略选择 -->
     <el-dialog :visible.sync="CKIddialogVisible" title="策略选择" width="78%">
           <el-form
        class="filter-container"
        ref="CKForm"
        :model="CKForm"
        label-width="110px"
      >
      <el-table-column label="序号"  type="index" width="60" align="center"></el-table-column>
        <el-row :gutter="20">
           <el-col :span="4">
             <el-form-item label="策略ID">
               <el-input placeholder="请输入内容" v-model="CKForm.strategy_id" clearable>
              </el-input>
              </el-form-item>
          </el-col>
           <el-col :span="4">
             <el-form-item label="策略类型">
                <el-select  clearable v-model="CKForm.strategy_type" class="filter-item" placeholder="请选择">
                 <el-option label="现货期货套期" value="1"></el-option>
                 <el-option label="现货现货套期" value="2"></el-option>
                  <el-option label="现货期权套期" value="3"></el-option>
                 <el-option label="期货期货套利" value="4"></el-option>
                  <el-option label="现货单边" value="5"></el-option>
                 <el-option label="期货单边" value="6"></el-option>
               </el-select>
              </el-form-item>
          </el-col>
           <el-col :span="4">
             <el-form-item label="策略名称">
               <el-input placeholder="请输入内容" v-model="CKForm.strategy_name" clearable>
              </el-input>
              </el-form-item>
          </el-col>
           <el-col :span="6">
            <el-form-item label="日期">
              <el-date-picker
              v-model="FYForm.date"
              type="date"
               value-format="yyyy-MM-dd"
                style="width:140px;"
              placeholder="选择日期">
            </el-date-picker>
            </el-form-item>
          </el-col>
           <el-col :span="4">
              <el-button type="primary" size="small" style='margin-top:3px;' @click="handle_CK">
                <d2-icon name="search"/> 查询
              </el-button>
            </el-col>
        </el-row>
      </el-form>
         <el-table :data="CKIdList" border highlight-current-row @current-change="handleCurrentChange_ta">
          <el-table-column type="index" label="序号"></el-table-column>
         <el-table-column prop="status" label="状态" sortable></el-table-column>
          <el-table-column prop="depart_name" label="部门名称" sortable></el-table-column>
          <el-table-column prop="strategy_name" label="策略名称" sortable></el-table-column>
          <el-table-column prop="strategy_id" label="策略ID" sortable></el-table-column>
          <el-table-column prop="strategy_type" label="策略类型" sortable></el-table-column>
          <el-table-column prop="strategy_objective" label="策略目的" sortable></el-table-column>
        </el-table>
         <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange1"
      :current-page="CKForm.currentPage"
      :page-size="CKForm.pageSize"
      layout="total, prev, pager, next"
      :total="CKForm.totalPage"
    >
    </el-pagination>
        <div slot="footer" class="dialog-footer">
            <el-button @click="CKIddialogVisible = false">取消</el-button>
            <el-button type="primary" @click="CKIdChange">保存</el-button>
        </div>
      </el-dialog>
  </d2-container>
</template>

<script>
import { conExposure, confuturesCap, addfuturesCap, constrategyinfo, concustomer, conspotreddashed, addspotreddashed, calculate, conspotCap, addspotCap, conCurrency, conFeetype } from '../../../../../api/url_lcc';
import { getDepartments } from '../../../../../api/url';
export default {
  name: "edit_QHcost",
//   components: {
//     "trade-name": tradeName
//   },
  data() {
    return {
      a:false,
      customerList:[],
      selectDepartsList:[],
        FYForm:{},
        CKIdList:[],
        fygltableData:[],
        selectCurrencyList: [],
        CKForm: {
        page: 1, //当前页
        pageSize: 20,
        totalPage: 1,
        status: "4",
        strategy_name: "",
        strategy_id: "",
        strategy_type: "",
        strategy_objective: "",
        department_name: "",
        creator: "",
        status: "",
        name: "",
        remark: "",
      },
        tableData: [],
        selectlistRow: [],
      rowNum: 1,
      CKIddialogVisible: false,
      row: "",
      asd2:"",
      cap_typeList:[]
    };
  },
  created() {
           this.tabledatas = [
               { title: '标题1', text: 's111sssa' },
               { title: '标题2', text: 'ss222ssa' },
           ]
           this.tabledatas.map(i => {
               i.show = false
               return i
           })
  },
  methods: {
     // 本币金额
      count1(){
          var original_price = this.FYForm.original_price;
          var exchange_rate = this.FYForm.exchange_rate;
          this.FYForm.currency_price = original_price*exchange_rate
      },
    //  部门信息
     //树形结构转换为扁平数组
    treeToList(tree) {
      var queen = [];
      var out = [];
      queen = queen.concat(tree);
      while (queen.length) {
        var first = queen.shift();
        if (first.sub_depart) {
          queen = queen.concat(first.sub_depart);
          delete first["sub_depart"];
        }
        out.push(first);
      }
      return out;
    },
     // 查询部门
    handle_getDepartments() {
      getDepartments()
        .then(res => {
          this.selectDepartsList = [];
          var data1 = res.result;
          var arr = this.treeToList(data1);
          for (var i = 0; i < arr.length; i++) {
            this.selectDepartsList[i] = {
              name: arr[i]["name"],
              department: arr[i]["id"]
            };
          }
        })
        .catch(err => {
          this.$message.error(err.msg);
        });
    },
     // 费用查询
    handlefee_typeChange(){
       let params = {
            "name": this.FYForm.name || "",
            "status": this.FYForm.status || "",
            "currency": this.FYForm.id || "",
        };
        conFeetype(params).then(res => {
            // if (res.errcode == "1") {
                this.cap_typeList = []
                var data = res.result
                for (var i = 0; i < data.length; i++) {
                  this.cap_typeList[i] = {
                    cap_type: data[i]['id'],
                    cap_type_name: data[i]['name'],
                  }
              }
            }).catch(err =>{
          this.$message.error(err.msg);
        });
    },
    selectcapItem(event, index) {
      [this.fygltableData[index]].forEach(item => {
        item.cap_type = event.cap_type;
        item.cap_type_name = event.cap_type_name;
      });
      console.log("fygltableData", this.fygltableData);
    },
    // 状态
    formatterStatus(row, column){
       if (row.status == "1") {
             return '草拟';
         } else if (row.status == "2") {
             return '审核中';
         } else if (row.status == "3") {
             return '已通过';
         } else if (row.status == "4") {
             return '已驳回';
         } else if (row.status == "5") {
             return '已失效';
         } 
    },
    // 策略类型
    formatterType(row, column){
       if (row.strategy_type == "1") {
             return '现货期货套期';
         } else if (row.strategy_type == "2") {
             return '现货现货套期';
         } else if (row.strategy_type == "3") {
             return '现货期权套期';
         } else if (row.strategy_type == "4") {
             return '期货期货套利';
         } else if (row.strategy_type == "5") {
             return '现货单边';
         }  else if (row.strategy_type == "6") {
             return '期货单边';
         } 
    },
    // 策略目的
    formatterObj(row, column){
       if (row.strategy_objective == "1") {
             return '盘面快期套利';
         } else if (row.strategy_objective == "2") {
             return '期现套利';
         } else if (row.strategy_objective == "3") {
             return '套期保值';
         } else if (row.strategy_objective == "4") {
             return '其他';
         }
    },
     // 敞口类型逐笔，净敞口
    formatterET(row, column) {
         if (row.exp_type == "0") {
             return '逐笔';
         } else if (row.exp_type == "1") {
             return '净敞口';
         } 
     },
     //  购销类型
    formatterDirection(row, column) {
         if (row.direction == "0") {
             return '采购';
         } else if (row.direction == "1") {
             return '销售';
         } 
     },
    //  费用类型
    // formatterCost(row, column) {
    //   if (row.status == "0") {
    //     return "交割手续费";
    //   } else if (row.status == "1") {
    //     return "仓储费";
    //   } else if (row.status == "2") {
    //     return "申报费";
    //   } else if (row.status == "3") {
    //     return "质押手续费";
    //   } else if (row.status == "4") {
    //     return "交易手续费调整";
    //   }
    // },
    // 行内编辑
    handleCellDataChange({ rowIndex, key, value, row }) {
      debbuger;
      console.log(rowIndex);
      console.log(key);
      console.log(value);
      console.log(row);
    },

    // 单选
    handleCurrentChange(currentRow, oldCurrentRow) {
      console.log(currentRow);
      console.log(oldCurrentRow);
    },
    // 多选
    handleSelectionChange(selection) {
      console.log(selection);
    },
     // 获取表格选中时的数据
      selectRow (val) {
        this.selectlistRow = val
      },
      // 增加行
      addRow () {
       	  var list = {
          rowNum:this.rowNum,
          strategy_name: "",
          strategy_id: "",
          strategy_type: "",
          strategy_objective: "",
          department_name: "",
          creator: "",
          status: "",
          name: "",
   		 };
        this.fygltableData.unshift(list)
        this.rowNum += 1;
      },
      // 删除方法
      // 删除选中行
      delData () {
        for (let i = 0; i < this.selectlistRow.length; i++) {
          let val = this.selectlistRow
          val.forEach((val, index) => {
            this.fygltableData.forEach((v, i) => {
              if (val.rowNum === v.rowNum) {
                // i 为选中的索引
                this.fygltableData.splice(i, 1)
              }
            })
          })
        }
        // 删除完数据之后清除勾选框
        this.$refs.table.clearSelection()
      },
      // 计算匹配金额----修改匹配金额
      countChange1(){
          let data = this.fygltableData
          var Newdata  = [];
          data.forEach(function(item, index) {
              var data1 = item.alloc_amount
              Newdata.push(Number(data1));
              // console.log(90,data1,91,Newdata,92,typeof(data1))
           })
           let params = {
               operation: "FEE",
               "alloc_amount": Newdata,
               "currency_price":this.FYForm.currency_price
           };
        calculate(params).then(res => {
            if (res.errcode == "1") {
                 var data = res.result
                 this.FYForm = {
                     currency_price: data.currency_price,
                     matched_price: data.matched_price,     
                     unmatched_price: data.unmatched_price, 
                     department: this.FYForm.department,
                     date: this.FYForm.date,
                     customer: this.FYForm.customer,
                     currency: this.FYForm.currency,
                     direction: this.FYForm.direction,
                     virtual: this.FYForm.virtual,
                     original_price: this.FYForm.original_price,
                     begin_flag: this.FYForm.begin_flag,
                     exchange_rate: this.FYForm.exchange_rate,
                     application: this.FYForm.application, 
                     invoices_no: this.FYForm.invoices_no,
                     remark: this.FYForm.remark
                 }
            } else {
                this.$message.error(res.msg);
            }
        });
        },
     // 查询币种
    handle_currencyChange() {
      let params = {
        name: "",
      };
      conCurrency(params).then((res) => {
        if (res.errcode == "1") {
          this.selectCurrencyList = [];
          var data1 = res.result;
          console.log(902);
          for (var i = 0; i < data1.length; i++) {
            this.selectCurrencyList[i] = {
              currency: data1[i]["id"],
              name: data1[i]["name"],
            };
          }
        } else {
          this.$message.error(res.msg);
        }
      });
    },
        // 获取传过来的参数
    editListAll() {
      console.log('获取传过来的参数QHcost',this.$route.params.type,this.$route.params.editList)
      this.fygltableData = []
      var data = this.$route.params.editList[0].futures_alloc_fee
      this.fygltableData = data
      //  for (var i = 0; i < data.length; i++) {
      //     this.fygltableData[i] = {
      //       alloc_amount: data[i].alloc_amount,
      //       cap_type: data[i].cap_type.toString(),
      //       cap_type_name: data[i].cap_type_name,
      //       exposure: data[i].exposure,
      //       id: data[i].id,
      //       remark: data[i].remark,
      //       spot_fee: data[i].spot_fee,
      //     };
      //   }
      this.type = this.$route.params.type;
      
      this.FYForm = {
        department: this.$route.params.editList[0].department,
        invoices_no: this.$route.params.editList[0].invoices_no,
        date: this.$route.params.editList[0].date,
        customer: this.$route.params.editList[0].customer,
        currency: this.$route.params.editList[0].currency,
        direction: this.$route.params.editList[0].direction.toString(),
        virtual: this.$route.params.editList[0].virtual,
        original_price: this.$route.params.editList[0].original_price,
        begin_flag: this.$route.params.editList[0].begin_flag.toString(),
        exchange_rate: this.$route.params.editList[0].exchange_rate,
        currency_price: this.$route.params.editList[0].currency_price,
        remark: this.$route.params.editList[0].remark,
        matched_price: this.$route.params.editList[0].matched_price,
        application: this.$route.params.editList[0].application,  
        application: this.$route.params.editList[0].application,    
	      unmatched_price: this.$route.params.editList[0].unmatched_price
      };
      console.log(211,this.FYForm)
    },
      // 保存
    FYglChange() {
      if (this.$route.params.type === "copy") {
        this.copy_FYglChange();
      } else if (this.$route.params.type === "edit") {
        this.edit_FYglChange();
      }
    },
//       // 修改保存handle_FYglChange
      edit_FYglChange(){
        console.log('已匹配金额',this.FYForm.matched_price,'原币金额',this.FYForm.original_price,'未匹配金额',this.FYForm.unmatched_price)
        if(this.FYForm.unmatched_price<0){
          this.$message.error("已匹配金额不能大于本币金额！");
        }else{
          let data = this.fygltableData
       var Newdata  = [];
       var asd2 = "";
       var data2 = "";
       data.forEach(function(item, index) {
           var data1 = item.cap_type_name
           Newdata.push(data1);
           var last=JSON.stringify(Newdata);
           var asd = last.replace(/"/g, "");
           var asd1 = asd.replace('[','');
           asd2 = asd1.replace(']','');
        })
        let params = {
            operation: "MOD",
            futures_cap: {
            department: this.FYForm.department,
            date: this.FYForm.date,
            direction: this.FYForm.direction,
            invoices_no: this.FYForm.invoices_no,
            currency: this.FYForm.currency,
            original_price: this.FYForm.original_price,
            exchange_rate: this.FYForm.exchange_rate,
            currency_price: this.FYForm.currency_price,
            customer: this.FYForm.customer,
            begin_flag: this.FYForm.begin_flag,
            application: this.FYForm.application,
            matched_price: this.FYForm.matched_price,
            unmatched_price: this.FYForm.unmatched_price,
            remark: this.FYForm.remark,
            cap_type_all: asd2,
          },
            futures_alloc_fee: this.fygltableData,
        };
        addfuturesCap(params).then(res => {
            if (res.errcode == "1") {
                this.$message.success(res.result);
                 this.$router.push('/arbitrage_tool/managed_futures?table=sixth');
                 this.closeing.closePage(this.$store.getters["d2admin/page/allPage"],this.$store.getters["d2admin/page/currentPage"])
            } else {
              console.log(1,res)
                this.$message.error(res.msg);
            }
        });
       
        }
       
        },
//       // 复制保存handle_FYglChange
      copy_FYglChange(){
      let data = this.fygltableData
       var Newdata  = [];
       var asd2 = "";
       var data2 = "";
       data.forEach(function(item, index) {
           var data1 = item.cap_type_name
           Newdata.push(data1);
           var last=JSON.stringify(Newdata);
           var asd = last.replace(/"/g, "");
           var asd1 = asd.replace('[','');
           asd2 = asd1.replace(']','');
        })

        let params = {
            operation: "ADD",
            futures_cap: {
            department: this.FYForm.department,
            date: this.FYForm.date,
            direction: this.FYForm.direction,
            currency: this.FYForm.currency,
            original_price: this.FYForm.original_price,
            exchange_rate: this.FYForm.exchange_rate,
            currency_price: this.FYForm.currency_price,
            customer: this.FYForm.customer,
            begin_flag: this.FYForm.begin_flag,
            application: this.FYForm.application,
            matched_price: this.FYForm.matched_price,
            unmatched_price: this.FYForm.unmatched_price,
            remark: this.FYForm.remark,
            cap_type_all: asd2,
          },
            futures_alloc_fee: this.fygltableData,
        };
        addfuturesCap(params).then(res => {
            if (res.errcode == "1") {
                this.$message.success(res.result);
                 this.$router.push('/arbitrage_tool/managed_futures?table=sixth');
                 this.closeing.closePage(this.$store.getters["d2admin/page/allPage"],this.$store.getters["d2admin/page/currentPage"])
            } else {
              console.log(1,res)
                this.$message.error(res.msg);
            }
        });
       
        },
     // 返回跳转
    handle_FH(){
      this.$router.push('/arbitrage_tool/managed_futures?table=sixth');
      this.closeing.closePage(this.$store.getters["d2admin/page/allPage"],this.$store.getters["d2admin/page/currentPage"])
    },
    // 策略查询
     handle_CK(){
      this.CKForm.page = 1;
      constrategyinfo(this.CKForm).then((res) => {
        if (res.errcode == "1") {
          this.CKIdList = [];
          this.CKForm.direction = this.FYForm.direction;
          var data = res.result.results;
          this.CKForm.totalPage = res.result.count;
          for (var i = 0; i <= data.length; i++) {
            this.CKIdList[i] = {
                strategy_name: data[i].strategy_name,
                strategy_id: data[i].strategy_id,
                depart_name: data[i].depart_name,
                strategy_type: data[i].strategy_type,
                strategy_objective: data[i].strategy_objective,
                department_name: data[i].department_name,
                creator: data[i].creator,
                status: data[i].status,
            };
          }
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    //  策略选择弹框
    CKIddia(index, row) {
      this.CKIddialogVisible = true;
      this.handle_CK()
      this.index_s=index
    },
    // 策略选择查询
    // 每页数
    handleSizeChange(val) {
      this.CKForm.pageSize = val;
      this.CKForm.page = 1;
      this.handle_CK();
    },
    // 当前页
    handleCurrentChange1(val) {
      this.CKForm.page = val;
      this.handle_CK();
    },
    // 单选
    handleCurrentChange_ta(val) {
       this.currentRow = val;
     },
     // 保存策略
    CKIdChange(index) {
      this.CKIddialogVisible = false;
      console.log('保存策略',this.currentRow);
      console.log('index',this.fygltableData,12,this.index_s)
      this.fygltableData[this.index_s.index].strategy=this.currentRow.strategy_id
      this.fygltableData[this.index_s.index].strategy_name=this.currentRow.strategy_name
    },
    tableRow({row,rowIndex}){
      row.index=rowIndex
    },
      
  },
  mounted(){
    this.handle_getDepartments();
    this.editListAll();
    this.handle_currencyChange();
    this.handlefee_typeChange();
  }
};
</script>
